<template>
  <div id="fu">
    <div id="desc">
      <i class="el-icon-s-check"></i>
      <span>信息维护</span>
    </div>

    <div class="contine">
      <el-row>
        <el-col :span="8" :offset="8">
          <!--表单内容-->
          <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="学号">
              <el-input v-model="form.studentNumber" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="姓名">
              <el-input v-model="form.studentName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="教学系">
              <el-input v-model="form.departmentName" :disabled="true"></el-input>
            </el-form-item>

            <el-form-item label="专业">
              <el-input v-model="form.majorName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="班级">
              <el-input v-model="form.className" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="Email">
              <el-input v-model="form.studentEmail"></el-input>
            </el-form-item>

            <el-form-item label="生日">
              <el-date-picker type="date" placeholder="选择日期" v-model="form.studentBirthday"></el-date-picker>
            </el-form-item>
            <el-form-item label="性别">
              <el-radio-group v-model="form.studentSex">
                <el-radio :label="0">男</el-radio>
                <el-radio :label="1">女</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="密码">
              <el-input v-model="form.studentPassword" show-password></el-input>
            </el-form-item>

            <el-form-item label="操作">
              <el-button type="primary" @click="onSubmit">确认更新</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>

  </div>
</template>

<script>
import {get, post} from "../../common/request";

export default {
  name: "StuUpdateInfo",
  data() {
    return {
      form: {
        studentNumber: "",
        studentName: "",
        departmentName: "",
        majorName: "",
        className: "",
        studentEmail: "",
        studentBirthday: "",
        studentSex: "",
        studentPassword: ""
      }
    }
  },
  methods: {
    getData() {
      get("/student/getInfo").then(x => {
        this.form = x.data
      })
    },
    onSubmit() {
      post("/student/updateInfo", this.form).then(x => {
        if (x.code === 1) {
          this.$message.success(x.msg)
          this.getData();
        } else {
          this.$message.error(x.msg)
        }
      })
    }
  },
  mounted() {
    this.getData();
  }
}
</script>

<style scoped>
#fu {
  padding: 0 15px;
  background-color: rgb(240, 240, 240);
}

#desc {
  font-size: 14px;
  padding: 15px 0;
}

.contine {
  background-color: white;
  border-radius: 3px;
  border: 1px solid lightgray;
  padding: 10px 30px;
}
</style>
